package gov.gfbzb.advice.util;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;

/**
 * @Author: 小宇
 * @CreateTime: 2023/8/9 20:11
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;
    @Schema(name = "code", description = "状态吗")
    private int code;
    @Schema(name = "message", description = "执行信息")
    private String message;
    @Schema(name = "data", description = "返回数据")
    private Object data;

    public static Result success(String message, Object data) {
        return new Result(200, message, data);
    }

    public static Result success(Object data) {
        return new Result(200, "", data);
    }

    public static Result error(String message, Object data) {
        return new Result(400, message, data);
    }

    public static Result error(int code, String message, Object data) {
        return new Result(code, message, data);
    }

    public static Result error(Object data) {
        return new Result(400, "", data);
    }
}
